using UnityEngine;
using UnityEngine.Playables;

namespace IQIGame.Onigao.GamePlay
{
    public class LightBehaviour : PlayableBehaviour
    {
        public AnimationCurve curve;

        private double startTime = -1;

        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            if (this.startTime < 0)
            {
                this.startTime = playable.GetTime();
            }
            var fCurTime = playable.GetTime();
            var fDuration = playable.GetDuration();

            var fRate = (fCurTime - this.startTime) / fDuration;
            var fValue = this.curve.Evaluate((float)fRate);
            BattleManager.Instance.ctrl.sceneCtrl.SetLight(fValue);
        }

        public override void OnBehaviourPlay(Playable playable, FrameData info)
        {
        }

        public override void OnBehaviourPause(Playable playable, FrameData info)
        {
        }
    }
}